package logic

import (
	"context"
	"fmt"
	"taobao/goods_srv/model/mysql"

	"taobao/goods_srv/internal/svc"
	"taobao/goods_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateAvatarInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateAvatarInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAvatarInfoLogic {
	return &UpdateAvatarInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateAvatarInfoLogic) UpdateAvatarInfo(in *user.UserAvatarRequest) (*user.UserAvatarResponse, error) {
	// todo: 修改用户头像
	fmt.Print("调用............")
	u := mysql.UserWeek{}
	err := u.UpdateAvatar(int(in.UserID), in.Avatar)
	if err != nil {
		logx.Error("用户头像修改失败", err)
		return nil, err
	}
	return &user.UserAvatarResponse{}, nil
}
